# Change toi match your CPU core count
environment 'production'


#
#app_dir = File.expand_path("../", __FILE__)
app_dir="/home/xiaoxiao/app/community"
shared_dir = "#{app_dir}/shared"
#
# # Default to production
rails_env = ENV['RAILS_ENV'] || "production"
#environment rails_env
#
# # Set up socket location
bind "unix://#{shared_dir}/sockets/puma.sock"

# # Logging
stdout_redirect "#{shared_dir}/log/puma.stdout.log", "#{shared_dir}/log/puma.stderr.log", true
#
# # Set master PID and state locations
pidfile "#{shared_dir}/pids/puma.pid"
state_path "#{shared_dir}/pids/puma.state"

threads 1, 6
workers 1
daemonize true
port 3000
#ctivate_control_app
preload_app!

on_worker_boot do
  require "active_record"
    ActiveRecord::Base.connection.disconnect! rescue ActiveRecord::ConnectionNotEstablished
    ActiveRecord::Base.establish_connection(YAML.load_file("#{app_dir}/config/database.yml")[rails_env])
end
before_fork do
  ActiveRecord::Base.connection_pool.disconnect!
end

